package datasv.framework_datasv;

import data.datafactory.DatabaseOperator;
import po.ModelPO;

public class GetModel {
	public static void main(String[] args) {
		System.out.println(new GetModel().getModel("001", "0000001"));
	}
	public ModelPO getModel(String collegeID,String modelID){
		return getInSql(collegeID, modelID);
	}
	private ModelPO getInSql(String collegeID,String modelID){
		DatabaseOperator op=new DatabaseOperator("college"+collegeID);
	
		if(!op.ifDatabaseExist()||!op.ifIDExist("plan_model_list", modelID)){
			return null;
		}
		String name=null;
		String m;
		m=op.getOneInform(modelID, "plan_model_list", "name");
		if(m!=null){
			name=m;
		}
		
		m=op.getOneInform(modelID, "plan_model_list", "headCredit");
		int h=-1;
		int t=-1;
		if(m!=null){
			h=Integer.parseInt(m);
		}
		
		m=op.getOneInform(modelID, "plan_model_list", "tailCredit");
		if(m!=null){
			t=Integer.parseInt(m);
		}
		return new ModelPO(modelID,name,h,t);
	}
}
